const paginationBev = Behavior({
  data: {
    dataArr: [],
    total: 0,
    isEmpty: false,
    loading: false
  },
  methods: {
    setMoreData (arr) {
      const newArr = [...this.data.dataArr, ...arr]
      this.setData({
        dataArr: newArr
      })
    },
    getCurrentStart () {
      return this.data.dataArr.length
    },
    hasMoreData () {
      const { total, dataArr } = this.data
      return total > dataArr.length
    },
    setTotal (total) {
      this.data.total = total
      if (total === 0) {
        this.setData({
          isEmpty: true
        })
      }
    },
    clearData () {
      this.setData({
        dataArr: [],
        total: 0,
        isEmpty: false
      })
    },
    isLocked() {
      return this.data.loading
    },
    setLocked(value) {
      this.setData({
        loading: value
      })
    }
  }
})

export { paginationBev }